package com.walterweimod.auxiliary_attributes.event;

import com.walterweimod.auxiliary_attributes.capability.ModCapabilities;
import com.walterweimod.auxiliary_attributes.capability.impl.BloodPoolValue;
import com.walterweimod.auxiliary_attributes.capability.impl.RageLayerValue;
import com.walterweimod.auxiliary_attributes.capability.impl.TenacityChargeValue;
import com.walterweimod.auxiliary_attributes.capability.impl.base.CapabilityProviderBase;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraftforge.event.AttachCapabilitiesEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

import static com.walterweimod.auxiliary_attributes.Auxiliary_attributes.*;

@Mod.EventBusSubscriber
public class AttachCapabilityEvent {
    @SubscribeEvent
    public static void onAttachCapabilityToLivingEntity(AttachCapabilitiesEvent<Entity> event){
        if (event.getObject() instanceof Player){
            event.addCapability(
                    new ResourceLocation(
                            MODID, TenacityChargeValue.getDescription()
                    ),
                    new CapabilityProviderBase<>(
                            new TenacityChargeValue(),
                            ModCapabilities.TENACITY_CHARGE_VALUE
                    )
            );

            event.addCapability(
                    new ResourceLocation(
                            MODID, RageLayerValue.getDescription()
                    ),
                    new CapabilityProviderBase<>(
                            new RageLayerValue(),
                            ModCapabilities.RAGE_LAYER_VALUE
                    )
            );

            event.addCapability(
                    new ResourceLocation(
                            MODID, BloodPoolValue.DESCRIPTION
                    ),
                    new CapabilityProviderBase<>(
                            new BloodPoolValue(),
                            ModCapabilities.BLOOD_POOL_VALUE
                    )
            );

            System.out.println("Attached Tenacity Charge Value capability to LivingEntity" + event.getObject().getClass());
        }
    }
}
